Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

volume command #1747

Merged
merged 3 commits into from
Jan 28, 2024
Merged

volume command #1747

merged 3 commits into from
Jan 28, 2024

Conversation

kostmo
Copy link
Member

@kostmo kostmo commented Jan 25, 2024

Measures the volume of an enclosed space.
A useful alternative to the path command for goal checking.

Demo

scripts/play.sh -i data/scenarios/Testing/1747-volume-command.yaml --autoplay --speed 2

@restyled-io restyled-io bot mentioned this pull request Jan 25, 2024
@kostmo kostmo requested a review from byorgey January 25, 2024 23:53
@kostmo kostmo added the L-Commands Built-in commands (e.g. move, try, if, ...) in the Swarm language. label Jan 25, 2024
@kostmo kostmo marked this pull request as ready for review January 25, 2024 23:53
@kostmo kostmo force-pushed the feature/volume-command branch 2 times, most recently from b09ef47 to 85dde7b Compare January 26, 2024 01:27
Copy link
Member

@byorgey byorgey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This command doesn't seem all that useful to me, but I'm guessing you must have some particular use case(s) in mind?

src/swarm-engine/Swarm/Game/Step/Flood.hs Show resolved Hide resolved
@kostmo
Copy link
Member Author

kostmo commented Jan 26, 2024

some particular use case(s) in mind?

Yes. I don't have a particular use case for player robots, but I envision some interesting gameplay mechanics involving "enclosure" when used by system robots/goal conditions. The integration test scenario is one example. In contrast with the gated-paddock scenario, which used the path command to test for a route to a surrounding "ocean" to determine enclosure by a fence, this volume command does not require an extra surrounding entity layer, so long as there exists a maximum expected enclosure size.

A few scenario ideas:

  1. Caterpillar robots that turn into butterflies when snugly enclosed in a cocoon
  2. Defeating opponents by trapping them
  3. Excavating a burrow or mine of sufficient size as a goal (in combination with portals)

@byorgey
Copy link
Member

byorgey commented Jan 26, 2024

Ah, OK, yes, those sound nice!

@kostmo kostmo requested a review from byorgey January 26, 2024 23:20
visitableNeighbors = filter (not . (`HashSet.member` visited tracking)) candidateNeighbors

-- It's cheaper to prepend the "visitableNeighbors" list because
-- it should in general be a shorter list than the "pending" list.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment seems a little misleading --- the reason for prepending the visitableNeighbors is because we're treating pending as a stack rather than a queue, not because it is more efficient (though I agree it will be). Regardless of which list is shorter, prepending the visitableNeighbors will take constant time per new neighbor, and hence $O(n)$ overall since each vertex occurs as a new neighbor at most once. Whereas appending visitableNeighbors will take time linear in the number of vertices in the queue, but the same vertices might be in the queue for multiple iterations, so we can end up doing more than $O(n)$ work appending.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reason for prepending the visitableNeighbors is because we're treating pending as a stack rather than a queue, not because it is more efficient (though I agree it will be)

Well, I originally went about this intending to implement BFS, until I got to this line and realized that appending to the pending list would be expensive (and I couldn't be bothered to use Seq instead of []). So I decided to prepend instead, which turned it into DFS.

@kostmo kostmo added the merge me Trigger the merge process of the Pull request. label Jan 28, 2024
@mergify mergify bot merged commit 42d4e54 into main Jan 28, 2024
12 checks passed
@mergify mergify bot deleted the feature/volume-command branch January 28, 2024 01:02
@byorgey byorgey added the CHANGELOG Once merged, this PR should be highlighted in the changelog for the next release. label Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CHANGELOG Once merged, this PR should be highlighted in the changelog for the next release. L-Commands Built-in commands (e.g. move, try, if, ...) in the Swarm language. merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants